﻿/***********************************************************************
 * <copyright file="DataObjectFactory.cs" company="B/S JSC">
 * -->    Copyright (C) statement. All right reserved
 * </copyright>
 * 
 * Created:   LinhMC
 * Email:    linhmc@B/S.vn
 * Website:
 * Create Date: Thursday, October 17, 2013
 * Usage: 
 * 
 * RevisionHistory: 
 * Date         Author               Description 
 * 
 * ************************************************************************/
using System.Configuration;

namespace DataSecurity.EntityFramework
{
    /// <summary>
    /// DataObjectFactory caches the connectionstring so that the context can be created quickly.
    /// </summary>
    public static class DataObjectFactory
    {
        private static readonly string ConnectionString;

        /// <summary>
        /// Static constructor. Reads the connectionstring from web.config just once.
        /// </summary>
        static DataObjectFactory()
        {
            string connectionStringName = ConfigurationManager.AppSettings.Get("ConnectionStringName");
            ConnectionString = ConfigurationManager.ConnectionStrings[connectionStringName].ConnectionString;
        }

        ///// <summary>
        ///// Creates the Context using the current connectionstring.
        ///// </summary>
        ///// <remarks>
        ///// Gof pattern: Factory method. 
        ///// </remarks>
        ///// <returns>Action Entities context.</returns>
        ///// LinhMC comment đợi đến khi có CSDL thực sẽ add vào.
        //public static BigTimeEntities CreateContext()
        //{
        //    return new BigTimeEntities(_connectionString);
        //}
    }
}
